package com.jian.java.controller;

import com.jian.java.Servlet.MyFilter;
import com.jian.java.Servlet.MyServlet;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Jiange
 * @create 2021-04-29-15:28
 */
@Configuration
public class ServletConfig {
    @Bean
    public ServletRegistrationBean servletRegistrationBean(){
        MyServlet myServlet = new MyServlet();
        return new ServletRegistrationBean(myServlet,"/my");
    }

    @Bean
    public FilterRegistrationBean<MyFilter> filterRegistrationBean(){
        MyFilter myFilter = new MyFilter();
        return new FilterRegistrationBean<>(myFilter,servletRegistrationBean());
    }
}
